<?php

abstract class Controller {
	
	private $layout = 'default';
	protected $vars = array();
	
	public function render($filename) {
		extract($this->vars);
		ob_start();
		require(LIB_DIR.'views/'.get_class($this).'/'.$filename.'.php');
		$content = ob_get_clean();
		if($this->layout == NULL) {
			echo $content;
		} else {
			require(LIB_DIR.'views/layout/'.$this->layout.'.php');
		}
	}
	
	function loadModel($name) {
		require_once(LIB_DIR.'models/'.strtolower($name).'.php');
		$this->$name = new $name();
	}
	
	public function setLayout($layout) {
		$this->layout = $layout;
	}
}
